home *** CD-ROM | disk | FTP | other *** search
/ Champak 142 / Volume 142 Oct 17 2011 - Damaged.iso / Games / mochi_hungryplush.swf / scripts / frame_40 / DoAction.as
Text File  |  2011-10-17  |  3KB  |  93 lines

  1. enemyFish._visible = false;
  2. fishies = new Array();
  3. fishMade = d = score = 0;
  4. minimumFishOnScreen = 7;
  5. maximumFishOnScreen = 15;
  6. frame = _currentframe;
  7. stop();
  8. _root.onEnterFrame = function()
  9. {
  10.    if(_currentframe == frame)
  11.    {
  12.       if(_root.fish._width < Stage.width)
  13.       {
  14.          fishFound = 0;
  15.          i = 0;
  16.          while(i < fishies.length)
  17.          {
  18.             if(fishies[i] == 1)
  19.             {
  20.                fishFound++;
  21.             }
  22.             i++;
  23.          }
  24.          if(fishFound < minimumFishOnScreen)
  25.          {
  26.             chanceOfNewFishComing = 0;
  27.          }
  28.          else if(fishFound < maximumFishOnScreen)
  29.          {
  30.             chanceOfNewFishComing = random(60);
  31.          }
  32.          if(chanceOfNewFishComing == 0)
  33.          {
  34.             enemyFish.duplicateMovieClip("newEnemyFish" + d,d++,{left:random(2),speed:random(6) + 2,scale:random(_root.fish.scale + 40) + 10,_y:random(Stage.height),newFish:true});
  35.             fishies[fishMade] = 1;
  36.             fishMade++;
  37.          }
  38.          i = 0;
  39.          while(i < fishies.length)
  40.          {
  41.             if(fishies[i] == 1)
  42.             {
  43.                _root["newEnemyFish" + i]._x += _root["newEnemyFish" + i].speed;
  44.                if(_root["newEnemyFish" + i].hitTest(_root.fish))
  45.                {
  46.                   if(_root["newEnemyFish" + i].scale <= _root.fish.scale)
  47.                   {
  48.                      fish.scale += 5;
  49.                      score += _root["newEnemyFish" + i].scale;
  50.                      removeMovieClip(_root["newEnemyFish" + i]);
  51.                      fishies[i] = 0;
  52.                   }
  53.                   else
  54.                   {
  55.                      nextFrame();
  56.                      clearScreen();
  57.                   }
  58.                }
  59.                if(_root["newEnemyFish" + i].left == 1)
  60.                {
  61.                   if(_root["newEnemyFish" + i]._x < - _root["newEnemyFish" + i]._width)
  62.                   {
  63.                      fishies[i] = 0;
  64.                      removeMovieClip(_root["newEnemyFish" + i]);
  65.                   }
  66.                }
  67.                else if(_root["newEnemyFish" + i]._x > Stage.width + _root["newEnemyFish" + i]._width)
  68.                {
  69.                   fishies[i] = 0;
  70.                   removeMovieClip(_root["newEnemyFish" + i]);
  71.                }
  72.             }
  73.             i++;
  74.          }
  75.       }
  76.       else
  77.       {
  78.          _root.gotoAndStop(_currentframe + 2);
  79.       }
  80.    }
  81. };
  82. clearScreen = function()
  83. {
  84.    i = 0;
  85.    while(i < fishies.length)
  86.    {
  87.       removeMovieClip(_root["newEnemyFish" + i]);
  88.       i++;
  89.    }
  90.    fishies = new Array();
  91.    fishMade = 0;
  92. };
  93.